package com.facebook.drawee.generic;

import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import com.facebook.common.internal.Preconditions;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.drawable.ScalingUtils.ScaleType;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;

public final class GenericDraweeHierarchyBuilder {
    public static final ScalingUtils.ScaleType DEFAULT_SCALE_TYPE = ScalingUtils.ScaleType.CENTER_INSIDE;
    public static final ScalingUtils.ScaleType DEFAULT_ACTUAL_IMAGE_SCALE_TYPE = ScalingUtils.ScaleType.CENTER_CROP;
    Resources mResources;
    public int DEFAULT_FADE_DURATION;
    Drawable mPlaceHolderImage;
    @Nullable ScalingUtils.ScaleType mPlaceHolderImageScaleType;
    public Drawable mRetryImage;
    public ScalingUtils.ScaleType mRetryImageScaleType;
    public Drawable mFailureImage;
    public ScalingUtils.ScaleType mFailureImageScaleType;
    public Drawable mProgressBarImage;
    public ScalingUtils.ScaleType mProgressBarImageScaleType;
    public ScalingUtils.ScaleType mActualImageScaleType;
    public List<Drawable> mBackgroundImageList;
    public List<Drawable> mOverlays;
    public Drawable mPressedStateOverlay;
    public RoundingParams mRoundingParams;

    public GenericDraweeHierarchyBuilder(Resources resources) {
        this.mResources = resources;
        this.DEFAULT_FADE_DURATION = 300;
        this.mPlaceHolderImage = null;
        this.mPlaceHolderImageScaleType = null;
        this.mRetryImage = null;
        this.mRetryImageScaleType = null;
        this.mFailureImage = null;
        this.mFailureImageScaleType = null;
        this.mProgressBarImage = null;
        this.mProgressBarImageScaleType = null;
        this.mActualImageScaleType = DEFAULT_ACTUAL_IMAGE_SCALE_TYPE;
        this.mBackgroundImageList = null;
        this.mOverlays = null;
        this.mPressedStateOverlay = null;
        this.mRoundingParams = null;
    }

    public final GenericDraweeHierarchy build() {
        Iterator<Drawable> iterator;
        if(this.mOverlays != null) {
            iterator = this.mOverlays.iterator();
            while(iterator.hasNext()) {
                Preconditions.checkNotNull(iterator.next());
            }
        }

        if(this.mBackgroundImageList != null) {
            iterator = this.mBackgroundImageList.iterator();
            while(iterator.hasNext()) {
                Preconditions.checkNotNull(iterator.next());
            }
        }
        return new GenericDraweeHierarchy(this);
    }

    public final GenericDraweeHierarchyBuilder setPlaceholderImage(Drawable placeHolderImage, @Nullable ScalingUtils.ScaleType placeHolderImageScaleType) {
        this.mPlaceHolderImage = placeHolderImage;
        this.mPlaceHolderImageScaleType = placeHolderImageScaleType;
        return this;
    }
}

